package com.wanshi.cloud.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wanshi.cloud.Result;
import com.wanshi.cloud.entity.User;
import com.wanshi.cloud.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 顽石教育-www.wanshi.com
 * @since 2021-09-03
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService iUserService;

    @GetMapping("/{id}")
     public Result findbyid(@PathVariable String id){

        User user=iUserService.findbyid(id);
        return Result.ok(user);
    }

    //查询所有
     @GetMapping
     public Result findall(){
         List<User>user=iUserService.findalll();
         return Result.ok(user);
     }



    //分页查询
    @GetMapping("/page/{page}/{size}")
    public Result findfenye(@PathVariable Integer page ,@PathVariable Integer size){
        Page pageinfo =iUserService.findbypage(page,size);
        return Result.ok(pageinfo);
    }
}
